import java.util.ArrayList;
import java.util.List;

public class Solution722 {
    public List<String> removeComments(String[] source) {
        boolean flag=false;
        List<String> ans=new ArrayList<>();
        String now="";
        for (String s : source) {
            if (flag){
                if (s.contains("*/")){
                    s=s.substring(s.indexOf("*/")+2);
                    flag=false;
                    boolean f=false;
                    int cur=0;
                    while (cur+1<s.length()){
                        if (s.charAt(cur)=='/'){
                            if (s.charAt(cur+1)=='/'){
                                s=s.substring(0,cur);
                                ans.add(now.concat(s));
                                f=true;
                                break;
                            }else if (s.charAt(cur+1)=='*'){
                                String m=s.substring(cur+2);
                                if (!m.contains("*/")){
                                    flag=true;
                                    s=s.substring(0,cur);
                                    now=s;
                                    f=true;
                                    break;
                                }else {
                                    int t=m.indexOf("*/");
                                    s=s.substring(0,cur).concat(m.substring(t+2));
                                    cur--;
                                }
                            }
                        }
                        cur++;
                    }
                    if (!f){
                        ans.add(now.concat(s));
                    }
                }
            }else {
                boolean f=false;
                int cur=0;
                while (cur+1<s.length()){
                    if (s.charAt(cur)=='/'){
                        if (s.charAt(cur+1)=='/'){
                            s=s.substring(0,cur);
                            ans.add(s);
                            f=true;
                            break;
                        }else if (s.charAt(cur+1)=='*'){
                            String m=s.substring(cur+2);
                            if (!m.contains("*/")){
                                flag=true;
                                s=s.substring(0,cur);
                                now=s;
                                f=true;
                                break;
                            }else {
                                int t=m.indexOf("*/");
                                s=s.substring(0,cur).concat(m.substring(t+2));
                                cur--;
                            }
                        }
                    }
                    cur++;
                }
                if (!f){
                    ans.add(s);
                }
            }
        }
        for (int i=0;i<ans.size();i++){
            if (ans.get(i).length()==0){
                ans.remove(i);
                i--;
            }
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(new Solution722().removeComments(new String[]{"/*Test program */", "int main()", "{ ", "  // variable declaration ", "int a, b, c;", "/* This is a test", "   multiline  ", "   comment for ", "   testing */", "a = b + c;", "}"}));
    }
}
